<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>

<html lang="zh">
<head>

	<jsp:include page="/commonPages/admin-meta.jsp" flush="true" />
	<!-- CSS files -->
	<jsp:include page="/commonPages/admin-style.jsp" flush="true" />
	<link href="css/style.css" rel="stylesheet">
	
</head>
<style type="text/css">

#zhuce {
	color:#f5f5f5;
	position:relative;
	left:60%;
	
	
}


</style>
<body class="full">
	   
            <div class="col-md-4 col-md-offset-4">
                <div class="login-panel panel panel-default">
                    <div class="panel-heading">
                        <!-- <p class="panel-title" >Record></p> -->
                        <ul class="nav nav-pills" id="nav nav-pills">
							<li>企业</li>
							<li>部门</li>
							<li>管理员</li>
							<li>个人</li>
						</ul>
    					 
                    </div>
                    <div class="panel-body">
                        <form role="form" id="login-form" onsubmit="return load()">
                            <fieldset>
                                <div class="form-group">
                                    <input class="form-control" id="name" placeholder="请输入帐号" name="email" type="text" autofocus>
                                </div>
                                <div class="form-group">
                                    <input class="form-control" id="pass" placeholder="请输入密码" name="password" type="password" value="">
                                </div>
                                <div class="checkbox">
                                    <label>
                                        <input name="remember" type="checkbox" value="Remember Me">记住我
                                    </label>
                                  
                                    <a id = "zhuce"   href="signup.jsp" >>>注册</a>
                                 
                                </div>
                                
                                <!-- Change this to a button or input when using this as a form -->
                                 <button id="sub-login" type="submit" class="btn btn-primary btn-block btn-flat" data-loading-text="请稍候...">登录</button>
                            </fieldset>
                        </form>
                    </div>
                </div>
           	
    </div>
	
	<!-- JS files -->
	
    <jsp:include page="/commonPages/admin-script.jsp" flush="true" />
     <script>
   
     var loginRole = "";
     
     var lis = document.getElementById("nav nav-pills").getElementsByTagName("li");
	  	for(var i = 0 ; i < lis.length ; i ++){
         lis[i].setAttribute("index",i);
         lis[i].onclick = function(){
             
         	for(var i = 0 ; i < lis.length ; i ++){
                 if(this.getAttribute("index") == i){
                 
                     lis[i].style.backgroundColor="#4C9FD9";
                     loginRole = lis[i].innerHTML;
						
                 }else{
                     
                 	lis[i].style.color="";
                     lis[i].style.backgroundColor="";
                     
                 }
             }
         }
     }
     
	  function load(){
		 
			var inp = $('#login-form');
			var username = inp.find('#name').val();
			var password = inp.find('#pass').val();
	
			$("#sub-login").button('loading');
			$.ajax({
				type:"POST",
				url:"user/login",
				data:{
					username : username,
					password : password,
					loginRole : loginRole,
					
				},
				error:function(a,b,c){
					alert('服务器请求失败');
					$("#sub-login").button('reset');
				},
				success:function(data){
					if(data == "登录成功！"){
						//if success
					   window.location.href = jsBasePath+"qq.jsp"
					
					}
					else{
						$("#sub-login").button('reset');
						alert(data);
					}
				}
			});
			return false;
		  }
    </script>
   
</body>
</html>